home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_06 / allison / abort.c < prev    next >
C/C++ Source or Header  |  1994-04-08  |  553b  |  33 lines

  1. LISTING 11 - Intercepts the SIGABRT (abort) signal
  2.  
  3. /* abort.c:    Handle SIGABRT */
  4.  
  5. #include <stdio.h>
  6. #include <signal.h>
  7. #include <stdlib.h>
  8.  
  9.  
  10. void abort_handler(int sig);
  11.  
  12. main()
  13. {
  14.     /* Install signal handler */
  15.     if (signal(SIGABRT,abort_handler) == SIG_ERR)
  16.         fputs("Error installing abort handler\n",stderr);
  17.  
  18.     abort();
  19.     abort();
  20.     return 0;
  21. }
  22.  
  23. void abort_handler(int sig)
  24. {
  25.     fputs("Abort signal intercepted\n",stderr);
  26. }
  27.  
  28. /* Output:
  29. Abort signal intercepted
  30. Abnormal program termination
  31. */
  32.  
  33.